<% layout('/layouts/default.html', {title: 'activity管理', libs: ['validate','ueditor','fileupload']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa fa-list-alt"></i> ${text(activity.isNewRecord ? '新增activity' : '编辑activity')}
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${activity}" action="${ctx}/activity/activity/save" method="post" class="form-horizontal">
			<div class="box-body">
				<div class="form-unit">${text('基本信息')}</div>
				<#form:hidden path="id"/>
				<div class="row">
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('标题')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="activityTitle" maxlength="255" class="form-control required"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('权重')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="weight" maxlength="255" class="form-control digits" placeholder="默认为最大"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('类别')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="activityType" dictType="ac_type" class="form-control required" />
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('位置')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
                                <#form:treeselect id="activityLocationCode" title="${text('区域选择')}" path="activityLocationCode" labelPath="activityLocation" canSelectRoot="true" canSelectParent="true" returnFullName="false" returnFullNameSplit="-" url="${ctx}/sys/area/treeData" class="" allowClear="true"/>
							</div>
						</div>
					</div>

				</div>
                    <#form:hidden path="activityContentId"/>
                <div class="row">
                        <div class="col-xs-6">
                            <div class="form-group">
                                <label class="control-label col-sm-4" title="">
                                                            <span class="required">
                                                                *
                                                            </span>
                                    ${text('内容')}：
                                    <i class="fa icon-question hide">
                                    </i>
                                </label>
                            </div>
                        </div>
                        <div class="col-sm-10 col-sm-offset-2">
                            <#form:ueditor name="contentEditor" value="${activityContent}" maxlength="10000" height="200" simpleToolbars="false" readonly="false" outline="false"/>
                        </div>
                    </div>
                 <br/>
				<div class="row">
                    <div class="col-xs-6">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                                                <span class="required hide">
                                                                    *
                                                                </span>
                                ${text('活动封面')}：
                                <i class="fa icon-question hide">
                                </i>
                            </label>
                            <div class="col-sm-8">
                                <label style="display: none">
                                    <#form:input path="activitySmimg" name="activitySmimg" id="activitySmimg" maxlength="255" class="form-control  required"/>
                                </label>
                                <img class="" src="${activity.activitySmimg}" id="showImg" onerror="this.src='/js/static/images/default.jpg'"/>
                                <div class="hidden">
                                    <#form:fileupload path="activitySmimg" id="upload" bizKey="${activity.id}" bizType="activity_photo" uploadType="image"  allowSuffixes=".jpg,.png,.jpeg" returnPath="true" filePathInputId="activitySmimg" isMini="true"  readonly="false"/>
                                </div>
                            </div>
                        </div>
                    </div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('活动时间')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="activityTime" readonly="true" maxlength="20" class="form-control Wdate required"
									dataFormat="datetime" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false});"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> ${text('备注信息')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:textarea path="remarks" rows="4" maxlength="500" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-10">
						<% if (hasPermi('activity:activity:edit')){ %>
							<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('保 存')}</button>&nbsp;
						<% } %>
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
$("#inputForm").validate({
	submitHandler: function(form){
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == Global.TRUE){
				js.closeCurrentTabPage(function(contentWindow){
					contentWindow.page();
				});
			}
		}, "json");
    }
});
$(document).ready(function () {
    $("#showImg").click(function () {
        $("#uploadfileLists").children().remove();
        $(".webuploader-element-invisible")[0].click();
    });
    $("#activitySmimg").change(function () {
        var url = $(this)[0].value;
        var arr = url.split("|");
        url = arr[arr.length-1];
        $(this)[0].value = url;
        $("#showImg")[0].src = $(this)[0].value;
    });
});
</script>